<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../../css/common.css" media="all">

	</head>

	<body>

		<div class="layui-fluid">
			<div class="layui-row" id="view">
				<form class="layui-form test_edit" lay-filter="test_detail">
					<div class="layui-card">
						<div class="layui-card-body">

							<div class="layui-card">
								<div class="layui-card-body">
									<div class="layui-form-item">
										<label class="layui-form-label">状态：</label>
										<div class="layui-input-block">
											<input type="radio" name="status" value="-1" title="拒绝">
											<!--<input type="radio" name="status" value="0" title="待审核">-->
											<input type="radio" name="status" value="1" title="通过" checked="">
										</div>
									</div>
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">姓名：</label>
								<div class="layui-input-block">
									<input type="text" name="name" placeholder="请输入姓名" autocomplete="off"
										class="layui-input">
								</div>
							</div>

							<div class="layui-form-item">
								<label class="layui-form-label">性别：</label>
								<div class="layui-input-block sex"></div>
							</div>
						<!-- <div class="layui-form-item">
						  <label class="layui-form-label">运营商类型：</label>
						  <div class="layui-input-block">
						    <select name="btype" lay-verify="required">
						      <option value="">请选择</option>
						      <option value="1" {{d.btype == '1' ? 'selected' : ''}}>省级</option>
						      <option value="2" {{d.btype == '2' ? 'selected' : ''}}>市级</option>
						      <option value="3" {{d.btype == '3' ? 'selected' : ''}}>县级</option>
						    </select>    
						  </div>
						</div> -->
						<div class="layui-form-item">
							<label class="layui-form-label">会员编号：</label>
							<div class="layui-input-block">
								<input type="text" name="memberid" lay-verify="required" placeholder="请输入会员编号"
									autocomplete="off" disabled class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">用户编号：</label>
							<div class="layui-input-block">
								<input type="text" name="userid" lay-verify="required" placeholder="请输入用户编号"
									autocomplete="off" disabled class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">手机号码：</label>
							<div class="layui-input-block">
								<input type="text" name="mobile" lay-verify="required" placeholder="请输入手机号码"
									autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item upvideo">
							<label class="layui-form-label">营业执照</label>
							<div class="layui-input-block">
								<button type="button" class="layui-btn layui-btn-normal"
									onclick="choose(4)">上传图片</button>
								<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
									<ul class="show_img_ul" id="license_pic"></ul>
								</blockquote>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">营业执照名称：</label>
							<div class="layui-input-block">
								<input type="text" name="license_name" placeholder="营业执照名称" autocomplete="off"
									class="layui-input" >
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">营业执照编号：</label>
							<div class="layui-input-block">
								<input type="text" name="license_code" placeholder="营业执照编号" autocomplete="off"
									class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">证照有效期</label>
							<div class="layui-input-block">
								<input type="checkbox" value="1" id="license_validity_type" name="license_validity_type" title="长期" >
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">日期范围</label>
								<div class="layui-inline" id="test-range">
									<div class="layui-input-inline">
										<input type="text" id="license_begin_date" name="license_begin_date" class="layui-input" placeholder="开始日期">
									</div>
									<div class="layui-form-mid">-</div>
									<div class="layui-input-inline">
										<input type="text" id="license_end_date" name="license_end_date" class="layui-input" placeholder="结束日期">
									</div>
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">经营区域</label>
							<div class="layui-input-block">
								<div class="layui-input-inline addr_inline">
									 <select name="prov_province_code" id="prov_province" lay-filter="prov_province" >
									 </select>
								</div>
								<div class="layui-input-inline addr_inline">
									 <select name="prov_city_code" id="prov_city" lay-filter="prov_city" >
									 </select>
								</div>
								<div class="layui-input-inline addr_inline" style="margin-right: 0;">
									<select name="prov_district_code" id="prov_district_code" lay-filter="prov_district_code">
									</select>
								</div>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">办公位置：</label>
							<div class="layui-input-block">
								<div id="map-container" style="height: 500px; border: 1px solid #d6ccd6;"></div>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">办公区域：</label>
							<div class="layui-input-block">
								<input type="text" name="area" placeholder="请输入办公区域" autocomplete="off"
									class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">详细地址：</label>
							<div class="layui-input-block">
								<input type="text" name="address" placeholder="请输入详细地址" autocomplete="off"
									class="layui-input">
							</div>
						</div>
						
						<div class="layui-form-item upvideo">
							<label class="layui-form-label">办公场地租房合同</label>
							<div class="layui-input-block">
								<button type="button" class="layui-btn layui-btn-normal"
									onclick="choose(1)">上传图片</button>
								<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
									<ul class="show_img_ul" id="contract_pics"></ul>
								</blockquote>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">办公场地现场图片</label>
							<div class="layui-input-block">
								<button type="button" class="layui-btn layui-btn-normal"
									onclick="choose(2)">上传图片</button>
								<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
									<ul class="show_img_ul" id="office_pics"></ul>
								</blockquote>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">签名</label>
							<div class="layui-input-block">
								<img style="width: 50%;height: 150px;" class="layui-upload-img" id="ID-upload-sign-img">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">申请人：</label>
							<div class="layui-input-block">
								<input type="text" name="add_by" placeholder="" autocomplete="off"
									class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">申请时间：</label>
							<div class="layui-input-block">
								<input type="text" name="addtime" placeholder="" autocomplete="off"
									class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">备注：</label>
							<div class="layui-input-block">
								<input type="text" name="remark" placeholder="请输入备注" autocomplete="off"
									class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">原因：</label>
							<div class="layui-input-block">
								<input type="text" name="cause" placeholder="请输入原因" autocomplete="off"
									class="layui-input">
							</div>
						</div>
						</div>
					</div>

					<div class="layui-form-item layui-layout-admin">
						<div class="layui-input-block">
							<div class="layui-footer" style="left: 0;">
								<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
		<script src="https://unpkg.com/layui@2.6.8/dist/layui.js"></script>
		<!-- <script src="../../../../layuiadmin/layui/layui.js"></script> -->
		<script src="../../../../js/jquery.min.js"></script>
		<script src="../../../../js/jquery.jqprint-0.3.js"></script>
		<script src="../../../../js/common.js"></script>
		<script src="https://webapi.amap.com/maps?v=1.4.15&key=2d30eff9da600d78fba843b033c4eecd"></script>
		<script>
			var positions; //获取接口的坐标
			var coordArr; //把接口的坐标转成数组
			var numArr; //把数组中的坐标转换成数字
			var marker; // 定义全局变量保存标记点对象
			var shopStation; //获取到店铺信息
			var setPosition; //修改位置的信息
			var area_name;
			
			//用来显示地图的函数
			function showMap() {
				console.log("接口坐标", numArr);
				// 初始化地图对象
				var map = new AMap.Map('map-container', {
					zoom: 12,
					center: numArr
				});
				console.log(map,'map5555')
				// 创建标记并添加到地图上
				var marker = new AMap.Marker({
					position: numArr,
					map: map,
					draggable: true,
					icon: new AMap.Icon({
						size: new AMap.Size(35, 35),
						image: 'https://webapi.amap.com/theme/v1.3/markers/n/mark_r.png',
						offset: new AMap.Pixel(-12, -24)
					}),
					cursor: 'move'
				});
				// 显示标记信息窗口
				showInfoWindow(marker, map, true); //调用弹出信息窗口函数
				// 监听标记的拖动事件
				marker.on('dragend', function(event) {
					// 当标记结束拖动后，记录新的坐标信息
					console.log('拖动后的坐标：' + event.lnglat.getLng() + ',' + event.lnglat.getLat());
					setPosition = event.lnglat.getLng() + ',' + event.lnglat.getLat()
					// 在标记旁边显示店铺信息和坐标信息
					showInfoWindow(marker, map, false); //调用弹出信息窗口函数
				});
				map.on('click',mapClick);
				    
				function mapClick(e){
					// $("#lon").val(e.lnglat.getLat())
					// $("#lat").val(e.lnglat.getLng())
					setPosition = e.lnglat.getLng() + ',' + e.lnglat.getLat()
					showInfoWindow(marker, map, true); //调用弹出信息窗口函数
					if(!marker){
						marker = new AMap.Marker();
						map.add(marker);
					}
					marker.setPosition(e.lnglat);
					map.setFitView(marker);
					shopStation=''
					console.log(setPosition,'55555555555')
					// console.log("lon:"+e.lnglat.getLat()+"，lat:"+e.lnglat.getLng())
					// console.log(e)
					return;
					 // 使用经纬度获取位置信息的接口（示例：使用高德地图的逆地址解析API）
					var url="https://restapi.amap.com/v3/geocode/regeo?output=json&location="+e.lnglat.getLng() + "," + e.lnglat.getLat() + "&key=2d30eff9da600d78fba843b033c4eecd&radius=1000&extensions=all"
					// 发送 GET 请求获取位置信息
					layui.$.ajax({
						url: url,
						method: "GET",
						success: function (response) {
							if (response.status === "1") {
								var address = response.regeocode.formatted_address;
								layui.$("#result").text("当前位置信息：" + address);
							} else {
								layer.msg("获取位置信息失败");
							}
						},
						error: function (xhr, status, error) {
							layer.msg("发生错误：" + error);
						}
					});
				
				}
			}
			
			function showInfoWindow(marker, map, isOpen) {
				// 在标记旁边显示店铺信息和坐标信息
				var setLnglat = marker.getPosition().getLng() + ',' + marker.getPosition().getLat();
				var content = '<div class="infoWindow" >' +
					// '<p>店铺信息：' + shopStation + '</p>' +
					'<p>坐标信息：' + setLnglat + '</p>' +
					'</div>';
				var infoWindow = new AMap.InfoWindow({
					offset: new AMap.Pixel(0, -30),
					content: content,
					closeButton: false //关闭小叉号
				});
				if (isOpen) {
					// 是否默认打开信息窗口
					infoWindow.open(map, marker.getPosition());
				} else {
					infoWindow.open(map, marker.getPosition());
				}
			}
			var _data = {
				id: getParam('id'),
			}
			layui.config({
				base: '../../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'form', 'laytpl', 'laydate', 'layedit', 'rate'], function() {
				var $ = layui.$,
					admin = layui.admin,
					laytpl = layui.laytpl,
					laydate = layui.laydate,
					upload = layui.upload,
					form = layui.form;
				var rate = layui.rate;
				var img_arr1 = [], 
					img_arr2 = [],
					img_arr3 = []
				
				//渲染
				var ins1 = rate.render({
					elem: '#score', //绑定元素
					half: true,
					value: _data.score,
					choose: function(value) {
						_data.score = value;
					}
				});
				sex_show('radio');

				payment_show('radio')
				laydate.render({
				    elem: '#test-range' ,//开始时间和结束时间所在 input 框的父选择器
				    //设置开始日期、日期日期的 input 选择器
					type:'date',
				    range: ['#license_begin_date', '#license_end_date']//数组格式为 layui 2.6.6 开始新增
				});

				//监听提交
				form.on('submit(demo1)', function(data) {
					// 阻止表单的默认提交行为
					event.preventDefault();
					var data = data.field;
					_data = Object.assign(_data, data);
					_data.office_pics = img_arr2.join(',');
                    _data.license_pic=img_arr3.join(',');
					_data.contract_pics = img_arr1.join(',');
					_data.atype='1'
					_data.positions=setPosition
					_data.apply_prov=$("#prov_province").val()
					_data.apply_area=$("#prov_city").val()
					_data.apply_district=$("#prov_district_code").val()
					_data.area_id=$("#prov_district_code").val()
					_data.area=_data.area
					_data.area_name=area_name
					console.log(_data,'_data')
					if(_data.license_pic==''){
						return layer.msg('请上传营业执照');
					}
					if($('#prov_province').val()==''||$('#prov_city').val()==''||$('#prov_district_code').val()==''){
						return layer.msg('请选择经营区域');
					}
					if(_data.positions==''){
						return layer.msg('请在地图上选择办公位置');
					}
					if(_data.area==''){
						return layer.msg('请输入办公区域');
					}
					if(_data.address==''){
						return layer.msg('请输入详细地址');
					}
					if(_data.office_pics==''){
						return layer.msg('请上传办公场地');
					}
					if(_data.contract_pics==''){
						return layer.msg('请上传办公场地租房合同');
					}
					var lock = false
					layer.confirm('确定要提交数据？', function() {
						if (!lock) {
							lock = true
							loading();
							if (_data.id) {
								submitdata(server.sys_agent_update);
							}
							// else {
							// 	delete _data.id;
							// 	submitdata(server.master_insert);
							// }
						}
					}, function() {
						layer.msg('取消操作');
					});
					return false;
				});

				function submitdata(_url) {
					$.post(_url, _data, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								layer.alert('操作成功', function() {
									parent.layer.closeAll();
									parent.layui.table.reload('test-table-operate');
								});
							} else {
								layer.msg(res.msg);
							}
							closeloading();
						} else {
							closeloading();
							layer.msg('服务器连接错误');
						}
					});
				};
				var alldata={}
				initdata();
				var lice_index=0
				function initdata() {
					$.get(server.sys_agent_detail, _data, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								var data = res.shop_agent_apply
								alldata=data.data
								form.val("test_detail", data.data);
								area_name=alldata.area_name
								$('#ID-upload-sign-img').attr('src',alldata.sign_pic)
								$('input[name=license_begin_date]').val(data.data.license_begin_date)
								if(data.license_validity_type=='1'){
									$('input[name=license_end_date]').val('')
								}else{
									$('input[name=license_end_date]').val(data.data.license_end_date)
								}
								
								createli(data.data.contract_pics, 'contract_pics', '1')
								createli(data.data.office_pics, 'office_pics', '2')  
								createli(data.data.license_pic, 'license_pic', '4')  
								
								if(res.shop_agent_apply.data.positions){
									positions = res.shop_agent_apply.data.positions;
									setPosition=positions
									coordArr = positions.split(",");
									numArr = [parseFloat(coordArr[0]), parseFloat(coordArr[1])];
								}else{
									numArr = ['113.665794','34.709496'];
								}
								shopStation = res.shop_agent_apply.data.shop_name;
								if (numArr != undefined) {
									showMap()
								}
								$(function(){
								  var input = $('input[name=license_begin_date]');
								  var input_enddate =  $('input[name=license_end_date]');
								  
								  var enddate_val = input_enddate.val();
								  var current_val = input.val();
								  var result_val = enddate_val.substr(0, 10); 
								  var result = current_val.substr(0, 10);  // 截取前 10 位字符
								  input.val(result);
								  input_enddate.val(result_val);
								  
								});
			

								form.render();
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
				}
				var areaList;
				setTimeout(()=>{
					$.getJSON('area.json', function (data) {
						areaList=data
						var list = "";
						var list = "<option value=''>请选择省</option>";
						for (var i in areaList) {
							list += "<option value='" + areaList[i].value + "'>" + areaList[i].text + "</option>";
						}
						$('#prov_province').html(list)  // 商户经营地区
						// 商户经营地区 赋值
						$("#prov_province").val(alldata.apply_prov);   // 公司类型 商户注册地址-省
						form.render('select', 'prov_province_code');
						getprovCityList('edit')  // 市
						getprovdistrictList('edit')  // 区
					})
					var prov_citylist;
					// select 商户经营地区-省 事件
					form.on('select(prov_province)', function(data){
						var elem = data.elem; // 获得 select 原始 DOM 对象
						var value = data.value; // 获得被选中的值
						var othis = data.othis; // 获得 select 元素被替换后的 jQuery 对象 
						getprovCityList()
					});
					function getprovCityList(type){
						let p_selectIndex = $('select[name=prov_province_code]').prop('selectedIndex');
						console.log(p_selectIndex,2)
						if(p_selectIndex>0){
							let p_index=p_selectIndex-1
							prov_citylist=areaList[p_index].children
							var list = "";
							var list = "<option value=''>请选择市</option>";
							for (var i in prov_citylist) {
								list += "<option value='" + prov_citylist[i].value + "'>" + prov_citylist[i].text + "</option>";
							}
							$('#prov_city').html(list)
						}
						
						record_type_show('option');
						if(type=='edit'){
							$("#prov_city").val(alldata.apply_area);   // 公司类型 商户注册地址
							form.render('select', 'prov_city_code');
						}
					}
					var prov_districtlist;
					// select 商户注册地址-市 事件
					form.on('select(prov_city)', function(data){
						var elem = data.elem; // 获得 select 原始 DOM 对象
						var value = data.value; // 获得被选中的值
						var othis = data.othis; // 获得 select 元素被替换后的 jQuery 对象
						getprovdistrictList()  // 区
					});
					// select 商户经营地区-区 事件
					form.on('select(prov_district_code)', function(data){
					    var elem = data.elem; // 获得 select 原始 DOM 对象
					    var value = data.value; // 获得被选中的值
					    var othis = data.othis; // 获得 select 元素被替换后的 jQuery 对象 
						let a_selectIndex = $('select[name=prov_district_code]').prop('selectedIndex');
						if(a_selectIndex>0){
							area_name=prov_districtlist[a_selectIndex-1].text
						}
					});
					function getprovdistrictList(type){
						let p_selectIndex = $('select[name=prov_city_code]').prop('selectedIndex');
						if(p_selectIndex>0){
							let p_index=p_selectIndex-1
							prov_districtlist=prov_citylist[p_index].children
							var list = "";
							var list = "<option value=''>请选择区</option>";
							for (var i in prov_districtlist) {
								list += "<option value='" + prov_districtlist[i].value + "'>" + prov_districtlist[i].text + "</option>";
							}
							$('#prov_district_code').html(list)
						}
						record_type_show('option');
						if(type=='edit'){ 
							$("#prov_district_code").val(alldata.apply_district);   // 公司类型 商户注册地址
							// form.render('select', 'prov_district_code');
							form.render('select');
						}
					}
				},1000)
				$(function() {
				  var validityYearInput = $('#validity_year');
				  var endDateInput = $('#license_end_date');
				
				 
				
				  // 监听加号按钮的点击事件
				  $('.add-btn').on('click', function() {
				    var year = parseInt(validityYearInput.val());
					console.log("加",validityYearInput.val(),year);
				if(validityYearInput.val() < 10){
					 year++;
					 validityYearInput.val(year );
					 updateValidityYear(1)
					
				}else{
					layer.msg('期年只能最大为10');
					 validityYearInput.val(10)
				}
				  });
				
				  // 监听减号按钮的点击事件
				  $('.minus-btn').on('click', function() {
				    var year = parseInt(validityYearInput.val());
					console.log("减",validityYearInput.val(),year);
					if(validityYearInput.val() > 1){
						 year--;
						 validityYearInput.val(year);
						 updateValidityYear(-1)
						
					}else{
						layer.msg('期年只能最小为1');
						 validityYearInput.val(1)
					}
					
				  });
				   function updateValidityYear(year) {
				      var endDateStr = endDateInput.val();
				      var regex = /\//g;
				      var endDateFormatted = endDateStr.replace(regex, "-");
				  
				      var endDate = new Date(endDateFormatted);
				      endDate.setFullYear(endDate.getFullYear() + year);
				  
				      var formattedEndDate = endDate.toLocaleDateString().replace(regex, "-");
				      endDateInput.val(formattedEndDate);
				    }
					
					window.choose = function(data) {
						layer.open({
							type: 2,
							title: '上传图片',
							shadeClose: false,
							shade: 0.5,
							maxmin: true, //开启最大化最小化按钮
							area: ['700px', '400px'],
							content: '../../model/up_report.html?type=' + data,
							end: function() {},
							success: function() {}
						});
					}
					window.getimg = function(data, type) { //当单击确定data是图片上传服务器后的地址 type是数字类型
						if (data) {
							switch (type) {
								case '1':
									createli(data, 'contract_pics', type)
									break;
								case '2':
									createli(data, 'office_pics', type)
									break;
								case '4':
									createli(data, 'license_pic', type)
									break;
								default:
									break;
							}
						}
					}
					window.delimg = function(i, type, _self) {  
 						console.log("这是啥啊",i,type,_self,this);
						console.log(img_arr1,img_arr2,"看看数组");
						var _type = String(type)
						var lock = false
						layer.confirm('确定要删除图片？', function(index) {
							if (!lock) {
								console.log("执行1");
								lock = true
								switch (_type) {
									case '1':
										img_arr1.splice(i, 1)
										break;
									case '2':
										img_arr2.splice(i, 2)
										break;
									case '4':
										img_arr3.splice(i, 4)
										break;
									default:
										break;
								}
								$(_self).parent().remove();
								layer.close(index)
							}
						}, function() {
							console.log("执行2");
							layer.msg('取消操作');
						});
					}
				  })
				  function createli(data, dom, type) { //当单击确定data是图片上传服务器后的地址 type是数字类型
				  	console.log("执行顺序3", data, "+", dom, type);
					if(type==4){
						// 营业执照
						if(lice_index==0){
							lice_index=lice_index+1
						}else{
							submitimgdata(data,'license')  // 营业执照
						}
					}
				  	console.log(data)
				  	var lihtml = '';
				  	switch (type) {
				  		case '1':
				  			if (data.indexOf(',') == -1) {
				  				img_arr1.push(data)
				  			} else {
				  				for (var i = 0; i < data.split(',').length; i++) {
				  					img_arr1.push(data.split(',')[i])
				  				}
				  			}
				  			for (var i = 0; i < img_arr1.length; i++) {
				  				lihtml += '<li class="show_img_li">' +
				  					'<img src=' + img_arr1[i] + ' >' +
				  					'<p onclick="delimg(' + i + ',1,this)">删除</p>' +
				  					'</li>'
				  			}
				  			break;
				  		case '2':
				  			if (data.indexOf(',') == -1) {
				  				img_arr2.push(data)
				  			} else {
				  				for (var i = 0; i < data.split(',').length; i++) {
				  					img_arr2.push(data.split(',')[i])
				  				}
				  			}
				  			for (var i = 0; i < img_arr2.length; i++) {
				  				lihtml += '<li class="show_img_li">' +
				  					'<img src=' + img_arr2[i] + ' >' +
				  					'<p onclick="delimg(' + i + ',2,this)">删除</p>' +
				  					'</li>'
				  			}
				  			break;
				  		case '4':
				  			if (data.indexOf(',') == -1) {
				  				img_arr3.push(data)
				  			} else {
				  				for (var i = 0; i < data.split(',').length; i++) {
				  					img_arr3.push(data.split(',')[i])
				  				}
				  			}
				  			for (var i = 0; i < img_arr3.length; i++) {
				  				lihtml += '<li class="show_img_li">' +
				  					'<img src=' + img_arr3[i] + ' >' +
				  					'<p onclick="delimg(' + i + ',4,this)">删除</p>' +
				  					'</li>'
				  			}
				  			break;
				  		default:
				  			break;
				  	}
				  	$('#' + dom).html(lihtml);
				}
				function submitimgdata(data,type){
					if(type=='license'){
						let _data={
							url:data
						}
						$.post(server.getbizlicense, _data, function(res, status) {
							if(status == 'success') {
								if(res.code=='0'){
									// 识别成功
									// $("select[name=license_type]").val("NATIONAL_LEGAL");   // 营业执照类型
									let license=JSON.parse(res.data)
									$("input[name=license_name]").val(license.Name) 
									$("input[name=license_code]").val(license.RegNum)
									$("#license_begin_date").val(license.Period.split('至')[0].replace("年","-").replace("月","-").replace("日",""))
						
									if(license.Period.indexOf("长期")==-1){
										$("#license_validity_type").attr('checked','false');   // 营业证照有效期
										$("#license_end_date").val(license.Period.split('至')[1].replace("年","-").replace("月","-").replace("日",""));
										$("#lice_date").val($("#license_begin_date").val()+' - '+$("#license_end_date").val())
									}else{
										$("#license_validity_type").attr('checked','true');   // 营业证照有效期
										$("#license_end_date").val('')
										$("#lice_date").val($("#license_begin_date").val()+' - 长期')
									}
									$("input[name=reg_detail]").val(license.Address);        // 注册详细地址
									// $("input[name=detail_addr]").val(license.Address);        // 经营详细地址
									
									var reg = /.+?(省|市|自治区|自治州|县|区)/g; // 省市区的正则
									var addrs = license.Address.match(reg);
									var sheng_code = "";
									var shi_code = "";
									var xian_code = "";
									console.log("省市区:"+addrs);
									if(addrs[0]){
										// obj.prov_name=addrs[0];
										let sheng = addrs[0];
										console.log(areaList,'areaList555')
										for(let p in areaList){
											if(sheng.indexOf(areaList[p].text)>-1){//匹配到省
												console.log("省市区:"+addrs);
												let adata = areaList[p];
												sheng_code = adata.value;
												if(addrs[1]&&adata.children){
													let shi = addrs[1];
													obj.area_name=shi
													for(let s in adata.children){
														if(shi.indexOf(adata.children[s].text)>-1){//匹配到市
															shi_code = adata.children[s].value;
															if(addrs[2]&&adata.children[s].children){
																let xian = addrs[2];
																obj.district_name = xian;
																for(let x in adata.children[s].children){
																	if(xian.indexOf(adata.children[s].children[x].text)>-1){//匹配到市
																		var xian_code = adata.children[s].children[x].value;
																		break;
																	}
																}
															}
														}
													}
												}
												
											}
										}
									}
									console.log("省市区:"+sheng_code+","+shi_code+","+xian_code);
								}
							} else {
								layer.msg('服务器连接错误');
							}
						});
					}
				}
			});
		</script>
	</body>

</html>
